<template>
<!--  分配维护人员-->
  <div>
    <zh-form ref="formInfo"  :rules="rules" :model="formInfo"  labelAlign="right" >
      <zh-card style="width:100%;float:left">
        <zh-row :span="18">
          <zh-input prop="orgIds" type="tree" label="请选择维护人员(可多选)" mode="multiple" placeholder="支持多选"
                    treeNodeFilterProp="title"
                    allowClear
                    multiple
                    tree-checkable
                    v-model="formInfo.userIdList"
                    :treeData="checkManTreeData"
                    :span="18"
                    style="float: left" :labelCol="{span:6}" :wrapperCol="{span:18}"
          >
          </zh-input>
        </zh-row>
        <div style="height: 50px">
        </div>
      </zh-card>
    </zh-form>
  </div>
</template>

<script>
import {TreeSelect} from "ant-design-vue";

import moment from 'moment'
import modal from "ant-design-vue/lib/modal";
import {allotMaintPersonBatch,getCheckManData
} from '@/services/system/whdngxlApi'

export default {
  components:{
  },
  props:{
    listQuery:{
      type:Function,
      default:null
    },
  },
  data() {
    return {
      formInfo:{
        userIdList:undefined,
      },
      rules: {
      },
      tags: [], // 用来存放页面上显示姓名标签
      checkManTreeData: [],
    }
  },

  created() {
    /*  const param = {}
      param.dictFields = 'ala040,blc512'
      this.$http.post(getBatchDict, param).then(res => {
        this.dictData = res.result
      })*/
  },
  methods: {
    moment,
    initData(manageAreas){
      //获取校核人员下拉列表
      const params = {}
      params.manageAreas = manageAreas
      this.$http.post(getCheckManData, params).then((res) => {
        if(res.result){
          this.checkManTreeData = res.result
        }
      }).catch((error) => {
        console.log(JSON.stringify(error))
      }).finally(() =>{
      })

    },
    allotMaintPersonBatch(b0101List){
      if(this.formInfo.userIdList == null || this.formInfo.userIdList.length === 0) {
        modal.warn({title: '温馨提示', content: '配置的维护人员不能为空'})
        return
      }
      if(b0101List.length === 0){
        modal.warn({title: '温馨提示', content: '无可保存数据!'})
        return
      }
      this.$loading.show('正在处理数据,请等待...')
      const params = {}
      params.b0101List = b0101List
      params.userIdList = this.formInfo.userIdList
      this.$http.post(allotMaintPersonBatch, params).then((res) => {
        this.$loading.hide()
        this.$message.info('保存成功')
        this.$emit("handleCancel")
        if(this.listQuery){
          this.listQuery()
        }
      }).catch((error) => {
        this.$loading.hide()
        console.log(JSON.stringify(error))
      }).finally(() =>{
      })
    },
  }
}
</script>

<style scoped>

</style>